using System;
using System.Collections.Generic;
using OrdersManager.Module.BusinessEntities;

namespace OrdersManager.Module.Services
{
	public class SimpleOrderRepository : IOrderRepository
	{
		private Dictionary<Guid, Order> _orders = new Dictionary<Guid, Order>();

		public void Update(Order order)
		{
			if (_orders.ContainsKey(order.Id))
			{
				_orders[order.Id] = order;
			}
		}

		public void Insert(Order order)
		{
			order.Id = Guid.NewGuid();
			_orders.Add(order.Id, order);
		}

		public Order GetById(Guid id)
		{
			if (_orders.ContainsKey(id))
				return _orders[id];
			else
				return null;
		}

		public bool Exists(Guid id)
		{
			return _orders.ContainsKey(id);
		}
	}
}